<?php namespace App\Services;

use App\Facades\Infra\SundrieManager;

class SundrieService{
	public function createSundrie($data){
		SundrieManager::createSundrie($this->formatData($data));
	}

	public function updateSundrie($data){
		$conditions['id'] = $data['id'];

		SundrieManager::updateSundrie($this->formatConditions($conditions),$data);
	}

	public function deleteSundrie($conditions){

		SundrieManager::deleteSundrie($conditions);
	}

	public function getSundrie($conditions){
		return SundrieManager::getSundries($this->formatConditions($conditions));
	}

	public function getSundries($conditions){
		return SundrieManager::getSundries($this->formatConditions($conditions),true)->orderBy('created_at','desc')->paginate(15);
	}

	private function formatData($data){
		$data['hotel_id'] = \Auth::user()->id;

		return $data;
	}

	private function formatConditions($conditions){
		$conditions['hotel_id'] = \Auth::user()->id;

		return $conditions;
	}
}